import React, {useState,useEffect} from 'react'
import Router from './router'
import { Route, Routes, useLocation } from 'react-router-dom'
import NotFind from './views/nofind'
import { ConfigProvider } from 'zarm';
import NavBar from './components/Nav';
//import zhCN from 'zarm/lib/config-provider/locale/zh_CN';
import 'lib-flexible'
export default function App() {

    const[showNav,setShowNav]=useState(false)
    const   { pathname } = useLocation()//获取当前路径
    //console.log(pathname);
    const needNav=['/','/data','/user']
    useEffect(()=>{
      setShowNav(needNav.includes(pathname))
    },[pathname])
   
    return (
        <ConfigProvider >
            <div className="page">
            <Routes>
                {
                    Router.map((item, index) => <Route path={item.path} element={<item.element />} key={index} />
                    )
                }
                <Route path='*' element={<NotFind />} key='nofind'></Route>
            </Routes>
            <NavBar showNav={showNav} />
            </div>
        </ConfigProvider>
    )
}